// 1.Vue：将data数据注入Vue实例，通过Object.definePropety将data转化为getter/setter
class Vue {
    constructor(options) {
        console.log(options)
        this.options = options || {}
        this.$data = options.data || {}
        const el = options.el
        this.$el = typeof el === 'string' ? document.querySelector(el) : el

        this.methods = options.methods

        this._proxyData(this.$data)

        new Observer(this.$data)

        new Compiler(this)
    }

    _proxyData(data) {
        Object.keys(data).forEach(key => {
            Object.defineProperty(this, key, {
                get() {
                    return data[key]
                },
                set(newValue) {
                    if(newValue === data[key]) {
                        return
                    }
                    data[key] = newValue
                }
            })
        })
    }

}